package com.dl7.mvp.video.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dl7.mvp.base.baseadapter.BaseRecyclerViewAdapter;
import com.dl7.mvp.video.bean.VideoInfo;
import com.dl7.mvp.mvp.R;

public class VideoAlbumDetailAdapter extends BaseRecyclerViewAdapter<VideoInfo> {
    private Context mContext;

    @Override
    public RecyclerView.ViewHolder onCreate(ViewGroup parent, int viewType) {
        mContext = parent.getContext();
        View layout = LayoutInflater.from(mContext).inflate(R.layout.album_detail_item, parent, false);
        return new VideoAlbumDetailAdapter.MyHolder(layout);
    }

    @Override
    public void onBind(RecyclerView.ViewHolder viewHolder, int RealPosition, VideoInfo data) {
        if (viewHolder instanceof VideoAlbumDetailAdapter.MyHolder) {
            VideoAlbumDetailAdapter.MyHolder holder = (VideoAlbumDetailAdapter.MyHolder) viewHolder;
            // 绑定数据
            Glide.with(mContext).load(data.getImage()).into(holder.image);
            holder.name.setText(data.getName());
        }
    }

    class MyHolder extends ViewHolder {
        ImageView image;
        TextView name;

        public MyHolder(View itemView) {
            super(itemView);
            image = itemView.findViewById(R.id.image);
            name = itemView.findViewById(R.id.name);
        }
    }
}
